package butines.game.lastcolony.screen;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import butines.core.GameImage;
import butines.core.gui.GUILabel;
import butines.core.gui.MouseEvent;
import butines.core.gui.style.Text;
import butines.core.gui.style.TextShadow;
import butines.game.lastcolony.LastColony;

public class GameStartScreen extends AbstractScreen {


	private GameImage background;
	private GUILabel campaign;
	private GUILabel multiplayer;
	private GUILabel quit;

    private Text menuText;
    private Text menuTexthovered;
    private TextShadow menuTextShadow;
	
	public GameStartScreen(LastColony game) {
		super(game);

		createStyle();
		createGui();
		
		background = new GameImage("images/splashscreen.png");
	}
	
	private void createStyle() {
        menuText = new Text(new Font("Courier New", Font.PLAIN, 48));
        menuText.setColor(Color.WHITE);

        menuTexthovered = menuText.copy();
        menuTexthovered.setColor(Color.YELLOW);

        menuTextShadow = new TextShadow();
        menuTextShadow.setText(menuText.copy());
        menuTextShadow.getText().setColor(new Color(128, 0, 128));
        menuTextShadow.add(2, 0);
        menuTextShadow.add(0, 2);
        menuTextShadow.add(0, -2);
        menuTextShadow.add(-2, 0);    
	}

	private GUILabel createLabel(int x, int y, String text) {
	    GUILabel label = new GUILabel(x, y, text);
        label.setTextShadow(menuTextShadow);
        label.setText(menuText);
        label.setTextHovered(menuTexthovered);
        label.setTextActived(menuTexthovered);
        label.setGuiListener(this);
        return label;
	}

	private void createGui() {
	    
        campaign = createLabel(70, 240, "Campaign");
        multiplayer = createLabel(70, 300, "Multiplayer");
        quit = createLabel(70, 360, "Quit");
        
        painel.add(campaign);
        painel.add(multiplayer);
        painel.add(quit);
        
	}
	
    @Override
    public void render(Graphics2D g2d) {
        background.draw(g2d, 0, 0);
    }

    @Override
    public void onClick(MouseEvent e) {
        if (e.getSource() == campaign) {
            lastColony.getSinglePlayer().start();
        }
        if (e.getSource() == quit) {
            lastColony.shutdown();
        }
    }

}